package com.iflysse.dao;

import java.util.List;

import org.apache.ibatis.annotations.Select;

import com.iflysse.dto.StudentCompleteTaskAllDto;
import com.iflysse.dto.StudentCompleteTaskDto;
import com.iflysse.dto.StudentTaskDto;
import com.iflysse.entity.TaskLearnRecord;
import com.iflysse.entity.TaskStudent;

public interface StudentTaskDao {
	
	/**
	 * 待学习任务接口列表
	 * @param studentId 学生学号
	 * @return 带学习课程
	 */
	@Select("SELECT * FROM tb_task a inner JOIN tb_task_student b ON a.task_id=b.task_id "
			+ " inner JOIN tb_task_learn_record c ON b.student_id=c.student_id "
			+ " INNER JOIN tb_teaching_class d ON  a.teaching_class_id=d.teaching_class_id INNER JOIN tb_course e ON e.course_id=d.course_id "
			+ " WHERE b.student_id=#{studentId} and state=0 AND resource_type=4 ORDER BY a.task_id ")
	List<StudentTaskDto> getTopFourWaitingTask(String studentId);
	/**
	 * 待学习任务接口前四个
	 * @param studentId 学生学号
	 * @return 待学习课程前四个
	 */
	@Select("SELECT * FROM tb_task a inner JOIN tb_task_student b ON a.task_id=b.task_id "
			+ " inner JOIN tb_task_learn_record c ON b.student_id=c.student_id "
			+ " INNER JOIN tb_teaching_class d ON  a.teaching_class_id=d.teaching_class_id INNER JOIN tb_course e ON e.course_id=d.course_id "
			+ " WHERE b.student_id=#{studentId} and state=0 AND resource_type=4 ORDER BY a.task_id ")
	List<StudentTaskDto> getWaitingTask(String studentId);
	
	/**
	 * 已学习任务接口
	 * @param studentId 学生学号
	 * @return 已学习课程所有
	 */
	@Select("SELECT * FROM tb_task a inner JOIN tb_task_student b ON a.task_id=b.task_id "
			+ " inner JOIN tb_task_learn_record c ON b.student_id=c.student_id "
			+ " INNER JOIN tb_teaching_class d ON  a.teaching_class_id=d.teaching_class_id "
			+ " INNER JOIN tb_course e ON e.course_id=d.course_id inner JOIN tb_student_test f ON f.student_id=b.student_id "
			+ " WHERE b.student_id=#{studentId} and state=1 AND resource_type=4 ORDER BY a.task_id")
	List<StudentCompleteTaskAllDto> getQueryCompleteTask(String studentId);
	
	
	/**
	 * 已学习任务接口前四个
	 * @param studentId 学生学号
	 * @return 
	 */
	@Select("SELECT * FROM tb_task a inner JOIN tb_task_student b ON a.task_id=b.task_id "
			+ " inner JOIN tb_task_learn_record c ON b.student_id=c.student_id "
			+ " INNER JOIN tb_teaching_class d ON  a.teaching_class_id=d.teaching_class_id "
			+ " INNER JOIN tb_course e ON e.course_id=d.course_id inner JOIN tb_student_test f ON f.student_id=b.student_id "
			+ " WHERE b.student_id=#{studentId} and state=1 AND resource_type=4 ORDER BY a.task_id")
	List<StudentCompleteTaskAllDto> getQueryTopFourCompleteTask(String studentId);
	
}
